package de.mhu.mandalaui.widgets;

import de.mhu.mandalaui.AbstractComposite;
import de.mhu.mandalaui.Response;
import de.mhu.mandalaui.AbstractComposite.Container;
import de.mhu.mandalaui.text.Text;

public class ButtonGroup extends AbstractComposite<Button, Object> {

	private boolean isGrouping = true;
	
	public void add(Button button) {
		add(button, null);
	}
	
	@Override
	public void render(Response response) {
		response.startTag("div", isGrouping ? "btn-group" : null, this);
		for (Container<Button, Object> item : this) {
			response.containerEnter(item.getItem());
			item.getItem().render(response);
			response.containerLeave();
		}
		response.endTag("div");
	}

	public String getStyleBase() {
		return "btn-group";
	}

	public boolean isGrouping() {
		return isGrouping;
	}

	public void setGrouping(boolean isGrouping) {
		this.isGrouping = isGrouping;
	}

}
